perm filename DSKSER.DOC[SS,SYS] blob sn#326063 filedate 1978-01-03 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00010 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	Various pieces of information about how DSKSER works.
C00007 00003	ACCESS:	compares other DDB's FILxxx with caller's ACCxxx
C00010 00004	RENAME
C00012 00005	ENTER
C00014 00006	LOOKUP
C00015 00007	CLOSE
C00017 00008	RELEASE (through RESET)
C00018 00009	Rename cases:
C00019 00010	UFD entry format:
C00020 ENDMK
C⊗;
Various pieces of information about how DSKSER works.

LOOKUP block:
	sixbit /NAME/
	sixbit /EXTENSION/,,byte(3)HI ORDER DATE WRITTEN (15)CREATION DATE
	byte (9)PROTECTION (4)MODE (11)TIME WRITTEN (12)LOW ORDER DATE WRITTEN
	sixbit /PPN/
	REFTIME (actually a date, not a time)
	DMPTIME (actually a date, not a time)

The retrieval that's left in the DDB after a successful LOOKUP or ENTER is
valid retrieval for the file being referenced.

It is not possible to ENTER a UFD in READ-ALTER mode.
It is not possible to ENTER a UFD to supercede an old one.
It is not possible to RENAME a UFD to a new name, extension or area.
It is possible to ENTER a new UFD.  When this happens, the retrieval
  of the new UFD should be (but isn't) correct before the entry is made in the MFD.
It is possible to RENAME an existing UFD to change the protection and times.
It is possible to do an MTAPE WRTINF to write the 4 word info for a UFD.
It is not possible to write the record offset with an MTAPE WRTOFF for a UFD.
It can happen that one job is reading a UFD while another tries to delete
it (with RENAME) causing DELETB to be set in the reader.
The only way to get write access to a UFD is to create a new UFD.

LOOKUP of a UFD as a file does not update REFTIM.

Create/delete of a UFD in parallel with either LOOKUP or ENTER of file in UFD
is not yet interlocked

LOGOUT updates time/date written of UFD with RENAME to indicate time
of last LOGOUT.

MTAPE for write info for a UFD SPREADs the new retrieval and has to get
the UFD interlock first.  This is what LOGIN does to store the time of
last login.  Also, any password or protection change by LOGIN is done with
either this MTAPE or a RENAME.

ENTER of a brand new file (not supercede) leaves HDRDIF and PNTDIF on
where it calls SPREAD explicitly.  Maybe check all explicit calls to SPREAD.

ENTER of a new file first puts the entry in the UFD and then SPREADs the
retrieval into the new file.  So if someone comes along and finds the UFD
entry and tries to read the file before the files retrieval has been spread,
he will get bad retrieval (once).  This can happen on creating a UFD in
parallel with trying to write a file in that UFD.  ENTER really should be
changed to output the retrieval before it makes the UFD entry.  Also, if the
system crashes after making the UFD entry but before writing the retrieval of
the first track and writing the SAT, then that track will be reassigned to
another file, which will cause bad retrieval for the first file.

The rule for UFD interlock is:
	Any interrupt subr that is going to change the retrieval of a UFD
	must:
	  1) get the UFD interlock for that UFD
	  2) read the retrieval from the disk into the DDB, since the
	     retrieval in the DDB is assumed to be stale.
	  3) change the retrieval in the DDB.
	  4) spread the retrieval to the file.
	  5) release the UFD interlock


Need to rearrange ENTER to write the track before writing the UFD entry
in case the system crashes inbetween.
ACCESS:	compares other DDB's FILxxx with caller's ACCxxx

ACCENT:	UUO args → ACCxxx and  REFTIM, DMPTIM if DMPBIT set.

DIRSRC:	call with SRCLOC set up to disk address of UFD to search.  Reads
	UFD into core.  Stores RH(UFDPR1) from LH(DQINFO+3) (the default
	file protection).  UFDPRO←DDPRO protection field (protection of
	UFD).  Searches for an entry matching SRCNAM, SRCEXT or just
	SRCNAM if it is 0.  If found SRCTMP,SRCLOC←location, SRCEXT←DDEXT
	and SRCPRO←DDPRO from the entry.  If SRCNAM WAS 0 and was found
	SRCTMP,SRCEXT←0.  If SRCNAM is not found, SRCTMP←-1, SRCEXT←0 or
	DDEXT of last partial match.  The UFD's retrieval is left in the
	DDB, TAC1 points at the entry in the appropriate SYSBUF, USETP
	points to the first record of the last track read.

SRCH:	SRCLOC←MFDLOC.  If ACCxxx is 1  1.UFD[1,1] then SRCTMP←MFDLOC,
	SRCEXT←MFDEXT, SRCPRO,UFDPRO←MFDPRO, DAT←0.
	IF ACCxxx is X.Y[1,1] go to SRCHU
SRCHM:	SRCNAM←ACCPPN, SRCEXT←UFDEXT
	If UFD name is cached, get address in SRCLOC, go to SRCHU.
SRCHM1:	Call int subr DIRSRC.  If SRCTMP ≤ 0 (not found) return.
	Do cacheing.
SRCHU:	SRCEXT←LH(ACCEXT), SRCNAM←ACCNAM, DAT←DIRSRC, skip return.

UFDSRC:	Call SRCH, if direct return then return.  If DAT = 0 ill MFD op.
	Skip return.

FILSRC:	Call SRCH, if direct return then return.
	If DAT ≠ 0 call int subr @DAT (DIRSRC).  Skip return if no errors.
	After a successful FILSRC, UFDPRO has protection of the UFD, UFDPR1
	has UFD's default protection, SRCNAM, SRCEXT, SRCPRO, SRCLOC are set
	up from the UFD entry.

DIRINS:	UFD location must be in SRCLOC and UFD name must be in DDNAM.
	Find a hole in the UFD for a new entry, extending the UFD if
	necessary.  The entry is made from ACCNAM, ACCEXT, ACCPRO, FILLOC, FILLNG
	The UFD's retrieval is left in the DDB.
RENAME

	FILxxx has current (old) file.
DRE0A:	ACCxxx←new file
	If name change go to DRNMC.
	If superceding go to DRE2.
	Call FILSRC to get UFD retrieval in.  Go to DRE2.

DRNMC:	If deleting go to DRDEL.
	Call FILSRC to get new UFD retrieval in.
	If the new file already exists, lose.

DRE2:
DRE3:	SRCLOC←DDLOC (location of new UFD)
	If not PPN change go to DREC1.
	If superceding go to DREC2.
	Call DIRINS to make entry in new UFD.
	Call SRCH1 (with TEM=FILNAM) to find old UFD.
DREC0:	Call int subr DR2INT (since not supercede) and done.
DREC1:	If not superceding call int subr DRINT and done.
DREC2:	Call int subr DRINT1 and done.


DRINT:	Call DRAUFD to update the old entry in the UFD.
DRINT1:	FILxxx←ACCxxx
	Fix retrieval and spread throughout file and done.

DR2INT:	Delete old UFD entry.

DRAUFD:
DRAUFY:	SRCNAM←FILNAM, SRCEXT←FILEXT
	Call DIRSRC to find entry in UFD.
	Change entry to ACCNAM, ACCEXT, ACCPRO, FILLOC, FILLNG
	Save old location in SRCLOC.  Write UFD back out and done.

DRDEL:	ACCxxx←FILxxx, ACCNAM←0.
	Call UFDSRC to find UFD location.
	Call int subr DRAUFD.
	If DELETE bit off, call DCLSOC to delete the file at old location
	(SRCLOC).
ENTER

	If LOOKUP already done go to DALTER.
	Call FILSRC to get UFD retrieval in and search for file.
	If filename not in use go to DENT1.
DENT1A:	Set NTRUFD and WRITEB.
DENT1:	Set WRITEB.
DENT2:	If DMPBIT go to DENT3.
	Update times, set HDRDIF.
DENT3:	If ALTERB go to ENTREN.
DENT3A:	Call ASNBLK, store new track address in FILLOC
	SRCLOC←DDLOC (UFD location if not supercede)
	FILLNG←0
	If not supercede, call DIRINS to insert file in UFD.
	Set up retrieval from audit info.
	Call NEWFI1, ASNGR1 to initialize retrieval.
	If not supercede, call SPREAD.
	Go to DRPT.

DALTER:	Check name, protection and accessors.  Go to DENT2

ENTREN:	Call FILSRC to find file (get UFD retrieval in DDB).
	Call DRE2 to finish rename and go to DRPT.
LOOKUP

	Call FILSRC to get UFD retrieval in and search for file.
	ACCEXT←SRCEXT, ACCPRO←SRCPRO
DLK3:	Set READB.  Call int subr LOOKI.
DRPT:	If not ALTERB then FILLNG←DDLNG.
	Store FILEXT, FILPRO and FILLNG (of part of file after offset) in user block
	REFTIM←DREFTM, DMPTIM←DDMPTM
	If DMPBIT store REFTIM and DMPTIM in user block
	Set USETP to offset and done

LOOKI:	FILLOC←SRCLOC
	Call NEWFIL.
LOKNXT:	Call GETBLK
	Update REFTIM and rewrite first track only.
CLOSE

CLOSE INPUT

DCLOSI:	If READB and DELETB and no other readers then call DELETE to delete
	the file.



CLOSE OUTPUT

DCLOSO:	(must have WRITEB or ALTERB)
	If PNTDIF or HDRDIF call int subr DCLOI to force out retrieval.
	If not supercede go to DCLSO2.
	Set DELETB in all readers of old file.
	Call UFDSRC to search for UFD in MFD.
	Call int subr DRAUFY to change UFD entry of superceded file to new
	file.
	If error from DRAUFY (didn't find old file) go to DCLSOF.
	If there were any readers of old file go to DCLSO2
DCLSOC:	TAC←old file loaction (from DRAUFY)
DCLSOD:	Call DELETE, go to DCLSO2.

DCLSOF:	Call DIRINS to insert new file in UFD.
DCLSO2:	Output SAT and done.

DCLOI:	If not PNTDIF go to DCLOI1
	SPREAD.  If DGRP1R=1 then clr HDRDIF.
DCLOI1:	If no HDRDIF go to DCLOI3
	If DGRP1R=1 then USETP←1 and call GGRETD.
	SPREAD.
DCLOI3:	If not NTRUFD and if UFDDIF then call UFDRTR.
	Done.

UFDRTR:	Read UFDTRK.
	ULEN←FILLNG
	Write back out.
RELEASE (through RESET)

DRELES:	Call DCLOSI
	If not WRITEB go to DRELS2
	Call int subr DCLOI
	If NTRUFD go to DRELS1
	Call UFDSRC, ACCNAM←0
	Call int subr DRAUFD to delete UFD entry
DRELS1:	Call DCLSOD to delete the file.
DRELS2:	Return buffers, clear DDB and done.
Rename cases:

Variables:
	1.  Name change (may be delete)
	2.  Current file is superceding an older one
	3.  UFD change

Cases:
	0.  change prot/dates
	1.  change name
	2.  change prot/dates of superceding file
	3.  change name of superceding file
	4.  change UFD
	5.  change name and UFD
	6.  change UFD of superceding file
	7.  change name and UFD of superceding file
UFD entry format:

UNAM:	0		;DDNAM
UEXT:	0		;DDEXT
UPRO:	0		;DDPRO
ULOC:	0		;DDLOC
ULEN:	0		;DDLNG
UTIME:	0		;EXTENDED TIME WRITTEN
UREFT:	0		;DREFTM   DATE LAST REFERENCED
UDMPT:	0		;DDMPTM   DATE LAST DUMPED
	0		;UNUSED (DGRP1R)
	0		;UNUSED (DNXTGP)
USATID:	0		;DSATID
UQINFO:	BLOCK 4		;DQINFO   SPECIAL STORAGE FOR LOGIN ETC.
UOFFST:	0		;DOFFST   RECORD OFFSET

Places that generate UFD entries:
	DRAUFY
	DIRINS
	UFDRTR
	DRPTI